API: Make _type read-only#1372
Merged
jku merged 1 commit intotheupdateframework:developfrom May 6, 2021
Merged
Conversation
Also remove _type from Signed constructor arguments: the value is in a class atttribute. This way _type never needs to be validated (except in the dispatcher in Metadata). There is a double-check in _common_fields_from_dict() just to be sure. This makes the API easier to use correctly as the public property is immutable. This is an API break as all Signed constructors change -- this could be avoided but seems like the correct choice. Signed-off-by: Jussi Kukkonen <jkukkonen@vmware.com>
joshuagl
approved these changes
May 4, 2021
Member
joshuagl
left a comment
There was a problem hiding this comment.
This looks reasonable to me. I like removing _type from the constructor and making the property read-only.
Given that this is an in-flux API, I'm not worried about the API break. Let's get this right before we promise something stable.
@woodruffw is not using the constructors directly in the PyPI/warehouse integration, IIRC. (However I think he already has changes to make as that WIP PR is using Metadata.from_json_file(), which has been renamed Metadata.from_file())
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Also remove
_typefrom Signed constructor arguments: the value is in aclass attribute. This way
_typenever needs to be validated (exceptin the dispatcher in Metadata). There is a double-check in
_common_fields_from_dict()just to be sure.This makes the API easier to use correctly as the public property is
immutable.
This is an API break as all Signed constructors change -- this could be
avoided but seems like the correct choice.
Signed-off-by: Jussi Kukkonen jkukkonen@vmware.com
Fixes #1371
The discussion-worthy aspects of this PR are: